import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);



export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: '/',
            component: () => import(/* webpackChunkName: "home" */ '../components/common/Home.vue'),
            meta: {title: '自述文件'},
            children: [
                {
                    path: '/dashboard',
                    name: 'dashboard',
                    component: () => import(/* webpackChunkName: "dashboard" */ '../components/page/Dashboard.vue'),
                    meta: {title: '系统首页'}
                },
                {
                    path: '/table',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/BaseTable.vue'),
                    meta: {title: '报修历史'}
                },
                {
                    path: '/tableComplain',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/tableComplain.vue'),
                    meta: {title: '投诉记录'}
                },
                {
                    path: '/tabs',
                    name: '/tabs',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/Tabs.vue'),
                    meta: {title: '公告栏'}
                },
                {
                    path: '/form',
                    name: 'form',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/BaseForm.vue'),
                    meta: {title: '报修'}
                },
                {
                    path: '/Assess',
                    name: 'Assess',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/Assess.vue'),
                    meta: {title: '评价'}
                },
                {
                    path: '/formComplain',
                    name: 'formComplain',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/formComplain.vue'),
                    meta: {title: '投诉'}
                },
                {
                    // 国际化组件
                    path: '/i18n',
                    component: () => import(/* webpackChunkName: "i18n" */ '../components/page/I18n.vue'),
                    meta: {title: '国际化'}
                },
                {
                    path: '/404',
                    component: () => import(/* webpackChunkName: "404" */ '../components/page/404.vue'),
                    meta: {title: '404'}
                },
                {
                    path: '/403',
                    component: () => import(/* webpackChunkName: "403" */ '../components/page/403.vue'),
                    meta: {title: '403'}
                },
            ]
        },
        {
            path: '/login',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/Login.vue'),
            meta: {title: '登录'}
        },
        {
            path: '/Register',
            component: () => import(/* webpackChunkName: "Regist" */ '../components/page/Register'),
            meta: {title: '注册'}
        },
        {
            path: '*',
            redirect: '/login'
        }
    ]

});
// const originalPush = Router.prototype.push;
// Router.prototype.push = function push(location, onResolve, onReject) {
//     if (onResolve || onReject)
//         return originalPush.call(this, location, onResolve, onReject);
//     return originalPush.call(this, location).catch((err) => err);
// };
// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题
// push

